package com.minhua.jijiehao2.mainframe.common.imagefragment.impl

import android.os.Bundle
import com.minhua.jijiehao2.mainframe.common.imagefragment.imp.IImageView
import cn.com.jd3601.mainframe.common.imagefragment.impl.ImagePresenter
import com.minhua.jijiehao2.R
import com.minhua.jijiehao2.base.BaseFragment
import kotlinx.android.synthetic.main.fragment_image.*

internal class ImageFragment : BaseFragment<IImageView, ImagePresenter>(), IImageView {
    override fun getLayoutId(): Int = R.layout.fragment_image

    override fun getPresenter(): ImagePresenter = ImagePresenter()

    private var imageResId: Int = 0

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        if (arguments != null) {
            imageResId = arguments.getInt(IMAGE_RES_ID)
        }
    }
    companion object {
        private val IMAGE_RES_ID = "imageResId"

        fun newInstance(imageResId: Int): ImageFragment {
            val fragment = ImageFragment()
            val args = Bundle()
            args.putInt(IMAGE_RES_ID, imageResId)
            fragment.arguments = args
            return fragment
        }
    }

    override fun initView() {
        ivImage.setImageResource(imageResId)
    }

}
